package cool.houge.pig.model;

import java.time.LocalDateTime;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.Persistable;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

/**
 * 令牌.
 *
 * @author KK (kzou227@qq.com)
 */
@Table("t_token")
@Data
@Accessors(chain = true)
public class Token implements Persistable<Long> {

  /** 是否为新的持久化数据. */
  private @Transient boolean isNew;

  /** 主键. */
  private @Id Long id;
  /** 用户 ID. */
  private @Column Long uid;
  /** 访问令牌. */
  private @Column("access_token") String accessToken;
  /** 刷新令牌. */
  private @Column("refresh_token") String refreshToken;
  /** 客户端 ID. */
  private @Column("client_id") String clientId;
  /** 授权类型. */
  private @Column("grant_type") String grantType;
  /** 作用域. */
  private @Column("scope") String scope;
  /** 创建时间. */
  private @Column("create_time") LocalDateTime createTime;

  public Token() {}

  /** @param isNew */
  public Token(boolean isNew) {
    this.isNew = isNew;
  }

  @Override
  public boolean isNew() {
    return this.isNew;
  }
}
